<extend name="Public/base"/>

<block name="body">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title">
        <h2>编辑用户</h2>
    </div>
    <ul class="tab-nav nav">
        <li class="current"><a href="javascript:void(0)">基本信息</a></li>
    </ul>

    <div class="tab-content">
        <form action="{:U()}" method="post" class="form-horizontal">
            <input type="hidden" class="text input-large" name="id" value="{$vo.id}">
            <div class="form-item">
                <label class="item-label">用户类型<span class="check-tips"></span></label>
                <div class="controls">
                    <select name="user_type" style="width:200px;" id="type">
                        <option value="1" <?php if($vo['user_type']==1){echo 'selected';} ?>>个人用户</option>
                        <option value="2" <?php if($vo['user_type']==2){echo 'selected';} ?>>企业用户</option>
                    </select>
                </div>
            </div>
            <div class="form-item">
                <label class="item-label" id="user">用户呢称<span class="check-tips">（用户呢称必须填写）</span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="username" value="{$vo.username}">
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">手机号码<span class="check-tips"></span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="mobile" value="{$vo.mobile}">
                </div>
            </div>
            <div class="form-item user">
                <label class="item-label">邮箱<span class="check-tips"></span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="email" value="{$vo.email}">
                </div>
            </div>
            <div class="form-item user" >
                <label class="item-label">生日<span class="check-tips">(生日格式:2000年9月10日)</span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="birthday" value="{$vo.birthday}">
                </div>
            </div>
            <div class="form-item user">
                <label class="item-label">性别<span class="check-tips"></span></label>
                <div class="controls">
                    <select name="sex" style="width:200px;">
                        <option value="1" <?php if($vo['sex']==1){echo 'selected';} ?>>男</option>
                        <option value="2" <?php if($vo['sex']==2){echo 'selected';} ?>>女</option>
                    </select>
                </div>
            </div>
            <div class="form-item shop" >
                <label class="item-label">详细地址<span class="check-tips"></span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="address" value="{$vo.address}">
                </div>
            </div>
            <div class="form-item shop">
                <label class="item-label">企业联系人<span class="check-tips"></span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="linkman" value="{$vo.linkman}">
                </div>
            </div>
            <div class="form-item shop">
                <label class="item-label">所属行业<span class="check-tips"></span></label>
                <div class="controls">
                    <select name="trade_id" style="width:200px;">
                        <volist name="trade" id="sty">
                            <option value="{$sty.id}" <?php if($vo['trade_id']==$sty[id]){echo 'selected';} ?>>
                            {$sty.title}</option>
                        </volist>
                    </select>
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">选择所在省<span class="check-tips">（省必须选择）</span></label>
                <div class="controls">
                    <select  style="width:200px;" id="n1" url="{:U('Usermember/get_up_city')}">
                        <option value="">请选择类别</option>
                        <volist name="province" id="sty">
                            <option value="{$sty.id}" <?php if($one['id']==$sty[id]){echo 'selected';} ?>>
                            {$sty.areaname}</option>
                        </volist>
                    </select>
                </div>
            </div>
            <div class="form-item"  id="form-item2">
                <label class="item-label">选择市<span class="check-tips">（市必须选择）</span></label>
                <div class="controls">
                    <select  style="width:200px;" id="n2">
                        <option value="{$two.id}">{$two.areaname}</option>

                    </select>
                </div>
            </div>
            <div class="form-item"  id="form-item3">
                <label class="item-label">选择区/县<span class="check-tips">（区/县分组必须选择）</span></label>
                <div class="controls">
                    <select name="city_id" style="width:200px;" id="n3">
                        <option value="{$three.id}">{$three.areaname}</option>
                    </select>
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">密码<span class="check-tips">（密码至少6位）</span></label>
                <div class="controls">
                    <input type="password" class="text input-large" name="password" value="{$vo.no_pass}">
                </div>
            </div>
            <div class="form-item" >
                <div class="controls">
                    <label class="item-label" id="user1">用户头像</label>
                    <input type="file" id="upload_picture">
                    <input type="hidden" name="icon" id="icon" value="{$vo['icon']|default=''}"/>
                    <div class="upload-img-box">
                        <notempty name="vo['icon']">
                            <div class="upload-pre-item"><img src="__ROOT__{$vo.icon|get_cover='path'}"/></div>
                        </notempty>
                    </div>
                </div>
                <script type="text/javascript">
                    //上传图片
                    /* 初始化上传插件 */
                    $("#upload_picture").uploadify({
                        "height"          : 30,
                        "swf"             : "__STATIC__/uploadify/uploadify.swf",
                        "fileObjName"     : "download",
                        "buttonText"      : "上传图片",
                        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                        "width"           : 120,
                        'removeTimeout'	  : 1,
                        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                        "onUploadSuccess" : uploadPicture,
                        'onFallback' : function() {
                            alert('未检测到兼容版本的Flash.');
                        }
                    });
                    function uploadPicture(file,data){
                        var data = $.parseJSON(data);
                        var src = '';
                        if(data.status){
                            $("#icon").val(data.id);
                            src = data.url || '__ROOT__' + data.path;
                            $("#icon").parent().find('.upload-img-box').html(
                                '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                            );
                        } else {
                            updateAlert(data.info);
                            setTimeout(function(){
                                $('#top-alert').find('button').click();
                                $(that).removeClass('disabled').prop('disabled',false);
                            },1500);
                        }
                    }
                </script>
            </div>
            <div class="form-item">
                <label class="item-label">是否启用<span class="check-tips"></span></label>
                <div class="controls">
                    <select name="status" style="width:200px;">
                        <option value="1" <?php if($vo['status']==1){echo 'selected';} ?>>启用</option>
                        <option value="0" <?php if($vo['status']==0){echo 'selected';} ?>>禁用</option>
                    </select>
                </div>
            </div>
            <div class="form-item">
                <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
                <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
            </div>
        </form>
    </div>
</block>

<block name="script">
    <include file="Public:datetime" />
    <script type="text/javascript">
        $(function () {
            var type=$('#type').val();
            if(type==1){
                $('.shop').hide();
                $('.user').show();
            }else {
                $('.shop').show();
                $('.user').hide();
                $('#user1').text('企业loge');
                $('#user').text('企业名称');

            }
            }
        );
        //切换用户类别
        $('#type').change(function () {
            var num=$('#type').val();
            if(num==1){
                $('.shop').hide();
                $('.user').show();
                $('#user1').text('用户头像');
                $('#user').text('用户呢称');
            }else {
                $('.user').hide();
                $('.shop').show();
                $('#user1').text('企业loge');
                $('#user').text('企业名称');

            }
        });
        //获取二级城市
        $('#n1').change(function () {
            var n1=$('#n1').val();
            var url=$('#n1').attr('url');
            console.log(n1);
            if(n1>0){
                $.ajax({
                    type: "POST",
                    url: url,
                    data:{id:n1},
                    success: function(data){
                        var string='<option value="">请选择类别</option>';
                        $('#n2').html(string+data);
                        $('#form-item2').show();
                    }
                });
            }
        });
        //获取三级城市分类
        $('#n2').change(function () {
            var n1=$('#n2').val();
            var url=$('#n1').attr('url');
            if(n1>0){
                $.ajax({
                    type: "POST",
                    url: url,
                    data:{id:n1},
                    success: function(data){
                        $('#n3').html(data);
                        $('#form-item3').show();
                    }
                });
            }
        });
        //导航高亮
        highlight_subnav('{:U('Usermember/index')}');
    </script>
</block>
